<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('教学物品数量登记')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="main-content">
        <form class="form-horizontal" id="form-user-edit" th:object="${teachGoods}">
            <input name="teachGoodsId"  type="hidden"  th:value="*{id}" />
            <input name="oldNum"  type="hidden"  th:value="*{nums}" />
            <h4 class="form-header h4">数量登记</h4>
            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">当前物品：</label>
                        <div class="col-xs-10">
                            <label  class="control-label">[[*{name}]]</label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">日期：</label>
                        <div class="col-sm-8">
                            <input id="recordDate" name="recordDate" placeholder="请填写日期" class="form-control" type="text" maxlength="30" required>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">数量：</label>
                        <div class="col-sm-8">
                            <input name="newNum" placeholder="请填写数量" class="form-control" type="text" maxlength="9" required>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-xs-2 control-label">异常原因：</label>
                        <div class="col-xs-10">
                            <textarea name="remark" maxlength="300" class="form-control" rows="3"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-offset-5 col-sm-10">
                    <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
                    <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
                </div>
            </div>
        </form>

        <h4 class="form-header h4">数量异动记录</h4>
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>异动人：</label>
                                <input type="text" name="createBy" placeholder="请输入姓名"/>
                                <input name="teachGoodsId2"  type="hidden"  th:value="${teachGoods.id}" />
                            </li>
                            <li>
                                异动机构：<select name="type" th:with="type=${@dict.getType('tenant_teach_goods_type')}" class="form-control">
                                <option value="">请选择</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictValue}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                异动类型：<select name="recordType" class="form-control">
                                <option value="">所有</option>
                                <option value="数量登记">数量登记</option>
                                <option value="物品领用">物品领用</option>
                            </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search('formId')"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('teach:goods:edit')}]];
        var superAdminFlag = [[${@permission.hasPermi('system:superAdmin:opt')}]];
        var prefix = ctx + "teach/goodsRecord";

        $("#form-user-edit").validate({
            onkeyup: false,
            rules:{
                orderNum:{
                    digits:true
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var data = $("#form-user-edit").serializeArray();
                $.operate.save(prefix + "/add", data);
            }
        }

        $("input[name='recordDate']").datetimepicker({
            autoclose: true,
            minView: "month",
            format: "yyyy-mm-dd",
            startDate: new Date()
        });

        $(function() {
            var options = {
                url: prefix + "/list",
                exportUrl: prefix + "/export",
                modalName: "数量异动记录",
                sortName: "id",
                sortOrder: "desc",
                search: "formId",
                columns: [{
                    checkbox: true
                },
                {
                    visible: false,
                    field: 'id',
                    title: '编号'
                },
                {
                    field: 'recordDate',
                    title: '异动日期'
                },
                {
                    field: 'unit',
                    title: '异动机构'
                },
                {
                    field: 'recordType',
                    title: '异动类型'
                },
                {
                    field: 'oldNum',
                    title: '异动前数量'
                },
                {
                    field: 'newNum',
                    title: '异动后数量'
                },
                {
                    title: '异动人',
                    align: 'center',
                    field: 'createBy'
                },
                {
                    title: '异动原因',
                    align: 'center',
                    field: 'remark'
                }
                ]
            };
            $.table.init(options);
            $.table.search("formId");
        });

    </script>
</body>
</html>